package books.new_to_old;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class TypeParamsJava {

    public static void main(String[] args) {

        try {
            Method test1 = TypeParamsJava.class.getDeclaredMethod("test1", null);
            Annotation[] annotations = test1.getDeclaredAnnotations();
            for (Annotation a : annotations) {
                System.out.println(a);
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

    }

    public void test() {
        //协变不能add
        ArrayList<? extends Number> list1 = new ArrayList<Integer>();
//        list1.add(new Integer(1));error

        ArrayList<? super Number> list2 = new ArrayList<Object>();
        //逆变可以add
        list2.add(new Integer(2));

    }

    public @Test String test1() {
        return "";
    }

}
